home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / faq-s.zip / GFILES.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-13  |  41KB  |  1,441 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,O+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit gfiles;
  5.  
  6. interface
  7.  
  8. uses crt,dos,overlay,
  9.      gentypes,configrt,modem,statret,subs1,subs2,textret,gensubs,
  10.      windows,mainr1,mainr2,overret1,userret,protocol,mainmenu,subs3;
  11.  
  12. procedure gfilesection;
  13.  
  14. implementation
  15.  
  16. procedure gfilesection;
  17. var showit,itsotay,ymodem:boolean;
  18.  
  19. var gfile:file of gfilerec;
  20.     gf:gfilerec;
  21.     gfilea:file of gfilearea;
  22.     gfa:gfilearea;
  23.     curarea:integer;
  24.  
  25. procedure beepbeep (ok:integer);
  26. begin
  27.  delay (500);
  28.  write (^B^M);
  29.  case ok of
  30.   0:write ('Transfer completed.');
  31.   1:write ('Transfer Aborted.');
  32.   2:write ('Transfer Aborted.')
  33.  end;
  34.  writeln (^G^M)
  35. end;
  36.  
  37. procedure parse3 (s:lstr; var a,b,c:integer);
  38. var p:integer;
  39.  
  40.   procedure parse1 (var n:integer);
  41.   var ns:lstr;
  42.   begin
  43.     ns[0]:=#0;
  44.     while (p<=length(s)) and (s[p] in ['0'..'9']) do begin
  45.       ns:=ns+s[p];
  46.       p:=p+1
  47.     end;
  48.     if length(ns)=0
  49.       then n:=0
  50.       else n:=valu(ns);
  51.     if p<length(s) then p:=p+1
  52.   end;
  53.  
  54. begin
  55.   p:=1;
  56.   parse1 (a);
  57.   parse1 (b);
  58.   parse1 (c)
  59. end;
  60.  
  61. function later (d1,t1,d2,t2:sstr):boolean;
  62. var m1,da1,y1,m2,da2,y2:integer;
  63.  
  64.   function latertime (t1,t2:sstr):boolean;
  65.   var n1,n2:integer;
  66.   begin
  67.     latertime:=timeval(t1)>timeval(t2)
  68.   end;
  69.  
  70.  begin
  71.    parse3 (d1,m1,da1,y1);
  72.    parse3 (d2,m2,da2,y2);
  73.    if y1=y2
  74.      then if m1=m2
  75.        then if da1=da2
  76.          then later:=timeval(t1) > timeval(t2)
  77.          else later:=da1>da2
  78.        else later:=m1>m2
  79.      else later:=y1>y2
  80.  end;
  81.  
  82.   function Numgfiles:integer;
  83.   begin
  84.     numgfiles:=filesize(gfile)
  85.   end;
  86.  
  87.   function NumAreas:integer;
  88.   begin
  89.     numareas:=filesize (gfilea)
  90.   end;
  91.  
  92.   procedure Seekgfile (n:integer);
  93.   begin
  94.     seek (gfile,n-1)
  95.   end;
  96.  
  97.   procedure Seekgfilea (n:integer);
  98.   begin
  99.     seek (gfilea,n-1)
  100.   end;
  101.  
  102.   procedure Assigngf (N:Integer);
  103.   begin
  104.     assign (gfile,uploaddir+'GFILE'+strr(n));
  105.     close (gfile);
  106.   end;
  107.  
  108.   function Makearea:boolean;
  109.   var num,n:integer;
  110.       gfatmp:gfilearea;
  111.   begin
  112.     makearea:=false;
  113.     writestr ('Create Area '+strr(numareas+1)+'? [y/n]: *');
  114.     writeln;
  115.     if yes then begin
  116.       writestr ('Area Name: *');
  117.       if length(input)=0 then exit;
  118.       gfatmp.Name:=input;
  119.       writestr ('Access Level: *');
  120.       if length(input)=0 then exit;
  121.       gfatmp.Level:=valu(input);
  122.       writestr ('Sponsor [CR/'+unam+']:');
  123.       if length(input)=0 then input:=unam;
  124.       gfatmp.Sponsor:=input;
  125.       gfatmp.UpAble:=True;
  126.       writestr('Able to Upload to area [CR/Yes]: *');
  127.       if length(input)=0 then input:='Y';
  128.       if upcase(input[1])<>'Y' then gfatmp.UpAble:=False;
  129.       writestr('Upload Directory [CR/'+uploaddir+']: *');
  130.       if length(input)=0 then input:=uploaddir;
  131.       gfatmp.gfileDir:=input;
  132.       Seekgfilea (numareas+1);
  133.       write (gfilea,gfatmp);
  134.       gfa:=gfatmp;
  135.       Curarea:=NumAreas+1;
  136.       Assigngf(CurArea);
  137.       rewrite (gfile);
  138.       writeln ('Area created');
  139.       makearea:=true;
  140.       writelog (3,6,gfatmp.Name);
  141.     end
  142.   end;
  143.  
  144.   procedure opengfile;
  145.   var n:integer;
  146.   begin
  147.     n:=ioresult;
  148.     assign (gfilea,uploaddir+'gfiledir.dat');
  149.     reset (gfilea);
  150.     if ioresult<>0 then begin
  151.       close (gfilea);
  152.       n:=ioresult;
  153.       rewrite (gfilea);
  154.       itsotay:=makearea;
  155.       if not itsotay then erase (gfilea);
  156.     end else itsotay:=true;
  157.   end;
  158.  
  159.   function getfname (path:lstr; name:mstr):lstr;
  160.   var l:lstr;
  161.   begin
  162.     l:=path;
  163.     if length(l)<>0 then
  164.       if not (upcase(l[length(l)]) in [':','\'])
  165.         then l:=l+'\';
  166.     l:=l+name;
  167.     getfname:=l;
  168.   end;
  169.  
  170.   function getapath:lstr;
  171.   var q,r:integer;
  172.       f:file;
  173.       b:boolean;
  174.       p:lstr;
  175.   begin
  176.     getapath:=gfa.gfiledir;
  177.     repeat
  178.       writestr ('Upload Path [CR/'+gfa.gfileDir+']:');
  179.       if hungupon then exit;
  180.       if length(input)=0 then input:=gfa.gfileDir;
  181.       p:=input;
  182.       if input[length(p)]<>'\' then p:=p+'\';
  183.       b:=true;
  184.       assign (f,p+'CON');
  185.       reset (f);
  186.       q:=ioresult;
  187.       close (f);
  188.       r:=ioresult;
  189.       if q<>0 then begin
  190.         writestr ('  Path does not exist.  Create it? [y/n]: *');
  191.         b:=yes;
  192.         if b then begin
  193.           mkdir (copy(p,1,length(p)-1));
  194.           q:=ioresult;
  195.           b:=q=0;
  196.           if b then writestr ('Directory created.')
  197.             else writestr ('Unable to create directory.')
  198.         end
  199.       end
  200.     until b;
  201.     getapath:=p;
  202.   end;
  203.  
  204.   procedure fastlistfile (n:integer);
  205.   var q:sstr;
  206.   begin
  207.     seekgfile (n);
  208.     read (gfile,gf);
  209.     writeln;
  210.     ansicolor (urec.promptcolor);
  211.     tab (strr(n)+'.',5);
  212.     ansicolor (urec.regularcolor);
  213.     if break then exit;
  214.     if gf.arcname='' then begin
  215.      if exist(getfname(gf.path,gf.fname)) then
  216.      tab (strlong(gf.filesize),9) else tab ('Offline',9);
  217.     end else tab ('Archived',9);
  218.     if break then exit;
  219.     ansicolor (urec.statcolor);
  220.     tab (gf.gfiledescr,66);
  221.     ansicolor (urec.regularcolor);
  222.     if break then exit;
  223.   end;
  224.  
  225.   function nofiles:boolean;
  226.   begin
  227.     if Numgfiles=0 then begin
  228.       nofiles:=true;
  229.       writestr (^M'Sorry, No G-Files!')
  230.     end else nofiles:=false
  231.   end;
  232.  
  233.   procedure fastlistgfiles;
  234.   var cnt,max,r1,r2,r3:integer;
  235.   begin
  236.     if nofiles then exit;
  237.     writehdr ('General File List');
  238.     max:=Numgfiles;
  239.     thereare (max,'G-File','G-Files');
  240.     parserange (max,r1,r2);
  241.     if r1=0 then exit;
  242.     tab ('No.',5);
  243.     tab ('Bytes',9);
  244.     tab ('Description',66);
  245.     writeln;
  246.     r3:=0;
  247.     for cnt:=r1 to r2 do begin
  248.     r3:=r3+2;
  249.       FASTlistfile (cnt);
  250.       if break then exit
  251.     end;
  252.     writeln;
  253.   end;
  254.  
  255.   function GetgfileNum (t:mstr):integer;
  256.   var n,s:integer;
  257.  
  258.     function SearchforFile (f:sstr):integer;
  259.     var cnt:integer;
  260.     begin
  261.       for cnt:=1 to numgfiles do begin
  262.         seekgfile (cnt);
  263.         read (gfile,gf);
  264.         if match(gf.fname,f) then begin
  265.           searchforfile:=cnt;
  266.           exit
  267.         end
  268.       end;
  269.       searchforfile:=0
  270.     end;
  271.  
  272.   begin
  273.     getgfilenum:=0;
  274.     if length(input)>1 then input:=copy(input,2,255) else
  275.       repeat
  276.         writestr ('File Number to '+t+' [?/List]:');
  277.         if hungupon or (length(input)=0) then exit;
  278.         if input='?' then begin
  279.           fastlistgfiles;
  280.           input:=''
  281.         end
  282.       until input<>'';
  283.     val (input,n,s);
  284.     if s<>0 then begin
  285.       n:=searchforfile(input);
  286.       if n=0 then begin
  287.         writeln ('No such file.');
  288.         exit
  289.       end
  290.     end;
  291.     if (n<1) or (n>numgfiles) then writeln ('Invalid number.')
  292.       else getgfilenum:=n
  293.   end;
  294.  
  295.   procedure addfile (gf:gfileRec);
  296.   begin
  297.     seekgfile (numgfiles+1);
  298.     write (gfile,gf)
  299.   end;
  300.  
  301.   function getfsize (filename:anystr):longint;
  302.   var df:file of byte;
  303.   begin
  304.     gf.filesize:=-1;
  305.     assign (df,filename);
  306.     reset (df);
  307.     if ioresult<>0 then exit;
  308.     getfsize:=filesize(df);
  309.     close(df)
  310.   end;
  311.  
  312.   const beenaborted:boolean=false;
  313.  
  314.   function Aborted:boolean;
  315.   begin
  316.     if beenaborted then begin
  317.       aborted:=true;
  318.       exit
  319.     end;
  320.     aborted:=xpressed or hungupon;
  321.     if xpressed then begin
  322.       beenaborted:=true;
  323.       writeln (^B'[New-Scan Aborted!]')
  324.     end
  325.   end;
  326.  
  327.   procedure NewScan;
  328.   var cnt:integer;
  329.       first:integer;
  330.       newest:boolean;
  331.   label notlater;
  332.   begin
  333.     newest:=false;
  334.     beenaborted:=false;
  335.     first:=0;
  336.     for cnt:=filesize(gfile) downto 1 do begin
  337.       Seekgfile (cnt);
  338.       read (gfile,gf);
  339.       if later (datestr(gf.when),timestr(gf.when),datestr(laston),timestr(laston))
  340.         then first:=cnt
  341.         else goto notlater
  342.     end;
  343.     notlater:
  344.     if first<>0 then begin
  345.       writeln;
  346.       writeln (^M'G-File Area: ['^S+gfa.name+^R']');
  347.       for cnt:=first to filesize(gfile) do begin
  348.         if aborted then exit;
  349.         fastlistfile (cnt);
  350.       end
  351.     end
  352.   end;
  353.  
  354.   procedure SetArea (n:integer);
  355.   var otay:boolean;
  356.   begin
  357.     curarea:=n;
  358.     otay:=false;
  359.     if (n>numareas) or (n<1) then begin
  360.       writeln (^B'Invalid Area!');
  361.       if issysop then if makearea then setarea (curarea)
  362.         else setarea (1)
  363.       else setarea (1);
  364.       exit
  365.     end;
  366.     seekgfilea (n);
  367.     read (gfilea,gfa);
  368.     otay:=(urec.gfLevel>=gfa.Level);
  369.     if not otay then
  370.       if curarea=1 then error ('Access Level too low!','','')
  371.         else begin
  372.           reqlevel (gfa.level);
  373.           setarea (1);
  374.           exit
  375.         end;
  376.     Assigngf(n);
  377.     close (gfile);
  378.     reset (gfile);
  379.     if ioresult<>0 then rewrite (gfile);
  380.     if showit then writeln (^B^M'G-File Area: '^S,gfa.name,^R' ['^S,curarea,^R']');
  381.     if showit=false then writeln;
  382.   end;
  383.  
  384.   procedure newscanall;
  385.   var cnt:integer;
  386.       otay:boolean;
  387.   begin
  388.     writehdr ('New-Scanning - Press [X] to abort.');
  389.     if aborted then exit;
  390.     for cnt:=1 to filesize(gfilea) do begin
  391.       seekgfilea (cnt);
  392.       read (gfilea,gfa);
  393.       otay:=false;
  394.       if urec.gfLevel>=gfa.Level then otay:=true;
  395.       if otay then begin
  396.         if aborted then exit;
  397.         setarea (cnt);
  398.         if aborted then exit;
  399.         newscan;
  400.       end;
  401.       if aborted then exit
  402.     end;
  403.   end;
  404.  
  405.   procedure listareas;
  406.   var cnt,old:integer;
  407.         gfatmp:gfilearea;
  408.   begin
  409.     writehdr ('Area List');
  410.     old:=curarea;
  411.     seekgfileA (1);
  412.     writeln(^M'Num Level   Name');
  413.     for cnt:=1 to NumAreas do begin
  414.       read (gfilea,gfatmp);
  415.       if (urec.level>=gfatmp.Level) then begin
  416.         write (^R,cnt:2,'. ['^S);
  417.          tab(strr(gfatmp.Level),5);
  418.         writeln(^R'] '^S,gfatmp.Name,^R);
  419.         if break then begin
  420.           setarea(old);
  421.           exit;
  422.         end;
  423.       end;
  424.     end;
  425.   end;
  426.  
  427.   function GetAreaNum:integer;
  428.   var areastr:sstr;
  429.       areanum:integer;
  430.   begin
  431.     getareanum:=0;
  432.     if length(input)>1 then areastr:=copy(input,2,255) else
  433.     begin
  434.     repeat
  435.       listareas;
  436.       writestr (^M'Area Number [?/List]:');
  437.       if input='!' then listareas else areastr:=input
  438.     until (input<>'?') or hungupon;
  439.     end;
  440.     if length(areastr)=0 then exit;
  441.     areanum:=valu(areastr);
  442.     if (areanum>0) and (areanum<=NumAreas) then getareanum:=areanum
  443.     else begin
  444.       writestr ('No such Area!');
  445.       if issysop then if makearea then getareanum:=numareas
  446.     end;
  447.   end;
  448.  
  449.   procedure GetArea;
  450.   var areanum:integer;
  451.   begin
  452.     areanum:=getareanum;
  453.     if areanum<>0 then SetArea (areanum);
  454.   end;
  455.  
  456.   procedure yourgfstatus;
  457.   begin
  458. if asciigraphics in urec.config then begin
  459. writeln (^B'┌─────────────────┬────────────────┐');
  460.     write ('│ G-File Level    │ '^S);
  461.     tab (strr(urec.gflevel),15);
  462.     writeln (^R'│');
  463.     write ('│ Required Ratio  │ '^S);
  464.     tab (strr(gfratio)+'%',15);
  465.     writeln(^R'│');
  466.     write ('│ G-file U/D Ratio│ '^S);
  467.         tab (strr(percent(urec.gfuploads,urec.gfdownloads)),15);
  468.     writeln (^R'│');
  469.     write ('│ G-File Uploads  │ '^S);
  470.     tab (strr(urec.gfuploads),15);
  471.     writeln (^R'│');
  472.     write ('│ G-File Downloads│ '^S);
  473.     tab (strr(urec.gfdownloads),15);
  474.     writeln (^R'│');
  475.     if useqr then begin
  476.      calcqr;
  477.     write ('│ Quality Rating  │ '^S);
  478.      tab (strr(qr),15);
  479.      writeln (^R'│');
  480.     end;
  481.   writeln ('└─────────────────┴────────────────┘');
  482.   end else begin
  483. writeln (^B'+-----------------+----------------+');
  484.     write ('| G-File Level    | '^S);
  485.     tab (strr(urec.gflevel),15);
  486.     writeln (^R'|');
  487.     write ('| Required Ratio  | '^S);
  488.     tab (strr(gfratio)+'%',15);
  489.     writeln(^R'|');
  490.     write ('| G-file U/D Ratio| '^S);
  491.         tab (strr(percent(urec.gfuploads,urec.gfdownloads)),15);
  492.     writeln (^R'|');
  493.     write ('| G-File Uploads  | '^S);
  494.     tab (strr(urec.gfuploads),15);
  495.     writeln (^R'|');
  496.     write ('| G-File Downloads| '^S);
  497.     tab (strr(urec.gfdownloads),15);
  498.     writeln (^R'|');
  499.     if useqr then begin
  500.      calcqr;
  501.     write ('| Quality Rating  | '^S);
  502.      tab (strr(qr),15);
  503.      writeln (^R'|');
  504.     end;
  505.   writeln ('+-----------------+----------------+');
  506.  end;
  507.   if percent (urec.gfuploads,urec.gfdownloads)<udratio then begin
  508.       writeln ('Your UL/DL ratio is too low!');
  509.       exit;
  510.       end;
  511.  end;
  512.  
  513.   procedure showgfile (n:integer);
  514.   var f,wipefile:file;
  515.       protop,tran,fn:lstr;
  516.       b:integer;
  517.       ascii,crcmode,ymodem,cool:boolean;
  518.       extrnproto:char;
  519.   begin
  520.     ascii:=false;
  521.     seekgfile (n);
  522.     read (gfile,gf);
  523.     if ulvl<0 then  exit;
  524.     writeln;
  525.     if useqr then begin
  526.      calcqr;
  527.      if (qr<qrlimit) and (ulvl<qrexempt) then begin
  528.      writeln ('Your Quality Rating is '^S+strr(qr)+^R'.');
  529.      writeln ('That exceeds the limit of '^S+strr(qrlimit)+^R'!');
  530.      writeln ('You must get a better QR before you can download.');
  531.      exit;
  532.     end;
  533.     end;
  534.     if (not exist(getfname(gf.path,gf.fname))) and (gf.arcname='') then begin
  535.       writeln('File is [Offline]!');
  536.       writeln;
  537.       exit;
  538.     end;
  539.     if (gf.arcname<>'') and (not exist (getfname(gf.path,gf.fname))) then begin
  540.      writeln;
  541.      writeln ('Extracting file from Archive -- Please hold...');
  542.      if not exist (gf.arcname) then begin
  543.       writeln ('Archive filename '+gf.arcname+' does not exist!');
  544.       exit;
  545.      end;
  546.      extract (gf.fname,gf.arcname,gf.path);
  547.      if not exist (gf.path+gf.fname) then begin
  548.       writeln ('File could not be extracted.    Sorry!');
  549.       writeln ('Leave '+sysopname+' Feedback about this please.');
  550.       exit;
  551.      end;
  552.      if exist (uploaddir+gf.fname) then writeln ('Extracted Successfully.');
  553.     end;
  554.  
  555.     listprotocols(0);
  556.  
  557.     if hungupon then exit;
  558.     writestr(^R+'Protocol '^P'['^R'A'^P'/'^S'Ascii'^P']'^S' - '^P'['^R'CR'^P'/'+^S+urec.defproto+^S'  Q'^R'uit'^P']'^R' &');
  559.     if hungupon then exit;
  560.     if length(input)=0 then extrnproto:=urec.defproto else extrnproto:=upcase(input[1]);
  561.     if upstring (input)='Q' then exit;
  562.     fn:=getfname (gf.path,gf.fname);
  563.     ascii:=(extrnproto='A');
  564.  
  565.     if tempsysop then begin
  566.       ulvl:=regularlevel;
  567.       tempsysop:=false;
  568.       writeurec;
  569.       bottomline
  570.     end;
  571.  
  572.     if not ascii then begin
  573.     cool:=findprot('S',extrnproto);
  574.     if not cool then exit;
  575.     writeln; writeln('Start your download now.');
  576.       b:=doext('S',extrnproto,gf.path,gf.fname,baudrate,usecom);
  577.       modeminlock:=false;
  578.       modemoutlock:=false;
  579.       beepbeep (b)
  580.     end;
  581.     if ascii then begin
  582.      writestr ('Press [X] to abort or [CR] to continue: *');
  583.      if upcase(input[1])='X' then exit;
  584.      writeln (^M^R'Title: '^S,gf.gfiledescr,
  585.               ^M^R'Date:  '^S,datestr (gf.when),
  586.               ^M^R'Time:  '^S,timestr (gf.when),^M);
  587.      printfile (getfname(gf.path,gf.Fname));
  588.      urec.gfdownloads:=urec.gfdownloads+1;
  589.      writeln (asciidownload);
  590.      writeln;
  591.     end;
  592.    if ((gf.arcname<>'') and (exist (getfname(gf.path,gf.fname)))) then
  593.    begin
  594.     assign (wipefile,getfname(gf.path,gf.fname));
  595.     erase (wipefile);
  596.    end;
  597.   end;
  598.  
  599.   procedure makeasciigfile (filename:anystr);
  600.   var t:text;
  601.       b:boolean;
  602.       yo:integer;
  603.       fname:lstr;
  604.   begin
  605.    assign (t,filename);
  606.    rewrite (t);
  607.    writeln;
  608.    if (asciigraphics in urec.config) then
  609.    writeln ('──────────────────────────────────────────────────────────') else
  610.    writeln ('----------------------------------------------------------');
  611.    writeln ('[Enter G-File now (Echo''d) - Type /S to Save, /A to Abort]');
  612.    if (asciigraphics in urec.config) then
  613.    writeln ('──────────────────────────────────────────────────────────') else
  614.    writeln ('----------------------------------------------------------');
  615.    writeln;
  616.    repeat
  617.     lastprompt:='Continue...'^M;
  618.     wordwrap:=true;
  619.     getstr (1);
  620.     b:=match(input,'/S') or match(input,'/A');
  621.     if not b then writeln (t,input)
  622.    until b;
  623.    textclose (t);
  624.    if match(input,'/A') then erase (t);
  625.    writelog (3,2,Filename);
  626. end;
  627.  
  628.   procedure uploadgfile;
  629.   var tx,t:text;
  630.       ascii,crcmode,bbb,cool:boolean;
  631.       yo:integer;
  632.       fname,tran,protop,fn:lstr;
  633.       extrnproto:char;
  634.       emmemm:minuterec;
  635.   begin
  636.     writeln;
  637.     crcmode:=false;
  638.     ymodem:=false;
  639.     if gfa.upable=false then begin
  640.      writeln ('Sorry, Uploading is not allowed in this area!');
  641.      writeln;
  642.      exit;
  643.     end;
  644.  
  645.     writehdr('Upload G-Files');
  646.     repeat
  647.      writestr ('Upload Filename: *');
  648.      if length(input)=0 then exit;
  649.     until validfname (input);
  650.     gf.fname:=input;
  651.     fn:=getfname(gfa.gfiledir,gf.fname);
  652.     if not exist(fn) then begin
  653.      writestr ('Description:     &');
  654.      gf.gfiledescr:=input;
  655.      assign (tx,fn);
  656.      listprotocols(1);
  657.      if hungupon then exit;
  658.     writestr(^R+'Protocol '^P'['^R'A'^P'/'^S'Ascii'^P']'^S' - '^P'['^R'CR'^P'/'+^S+urec.defproto+^S'  Q'^R'uit'^P']'^R' &');
  659.     if hungupon then exit;
  660.     if length(input)=0 then extrnproto:=urec.defproto else extrnproto:=upcase(input[1]);
  661.     if upstring (input)='Q' then exit;
  662.  
  663.     ascii:=(extrnproto='A');
  664.  
  665.     if tempsysop then begin
  666.       ulvl:=regularlevel;
  667.       tempsysop:=false;
  668.       writeurec;
  669.       bottomline
  670.     end;
  671.  
  672.     starttimer (emmemm);
  673.     if not ascii then begin
  674.       ascii:=false;
  675.       yo:=0;
  676.       gf.arcname:='';
  677.       cool:=findprot('R',extrnproto);
  678.       if not cool then exit;
  679.  
  680.       yo:=doext('R',extrnproto,gfa.gfiledir,gf.fname,baudrate,usecom);
  681.  
  682.       modeminlock:=false;
  683.       modemoutlock:=false;
  684.  
  685.       beepbeep (yo);
  686.       case yo of
  687.         0    : writelog (3,2,fn);
  688.         1,2    : begin
  689.                 assign(tx,fn);
  690.                 erase(tx);
  691.               end;
  692.         end;
  693.     end;
  694.  
  695.     if ascii then begin
  696.      assign (t,fn);
  697.      rewrite (t);
  698.      writeln;
  699.      if (asciigraphics in urec.config) then
  700. writeln ('─────────────────────────────────────────────────────────────────') else
  701. writeln ('-----------------------------------------------------------------');
  702. writeln ('Enter G-File now (Echoed)  -  [/S] to Save, [/A] to Abort');
  703.      if (asciigraphics in urec.config) then
  704. writeln ('─────────────────────────────────────────────────────────────────') else
  705. writeln ('-----------------------------------------------------------------');
  706.      writeln;
  707.      repeat
  708.       lastprompt:='Continue...'^M;
  709.       wordwrap:=true;
  710.       getstr (1);
  711.       bbb:=match(input,'/S') or match(input,'/A');
  712.       if not bbb then begin
  713.        writeln (t,input);
  714.       end;
  715.      until bbb;
  716.      textclose (t);
  717.      if match(input,'/A') then erase (t);
  718.      writelog (3,2,fn);
  719.     end
  720.     end else writeln (^M'File exists!'^M);
  721.     stoptimer (emmemm);
  722.     writeln;
  723.     if not exist (fn) then begin
  724.      writeln ('Upload Aborted!');
  725.      exit;
  726.     end else writeln ('Thanks for the upload!');
  727.     gf.when:=now;
  728.     gf.sentby:=unam;
  729.     gf.path:=gfa.gfiledir;
  730.     gf.downloaded:=0;
  731.     gf.specialfile:=false;
  732.     gf.newfile:=true;
  733.     gf.filesize:=getfsize (fn);
  734.     urec.gfuploads:=urec.gfuploads+1;
  735.     seekgfile (numgfiles+1);
  736.     write (gfile,gf);
  737.     if gfilez>32760 then gfilez:=0;
  738.     gfilez:=gfilez+1;
  739.     writeln;
  740.     writelog (3,10,gf.gfiledescr)
  741.  end;
  742.  
  743.   procedure sysopcommands;
  744.   var q:integer;
  745.  
  746.     procedure getstr (prompt:mstr; var ss; len:integer);
  747.     var a:anystr absolute ss;
  748.     begin
  749.       writeln (^B^M'Current ',prompt,' is: '^S,a);
  750.       buflen:=len;
  751.       writestr ('Enter new '+prompt+':');
  752.       if length(input)>0 then a:=input;
  753.     end;
  754.  
  755.     procedure getint (prompt:mstr; var i:integer);
  756.     var q:sstr;
  757.         n:integer;
  758.     begin
  759.       str (i,q);
  760.       getstr (prompt,q,5);
  761.       n:=valu (q);
  762.       if n<>0 then i:=n
  763.     end;
  764.  
  765.     procedure getboo (t:lstr; var b:boolean);
  766.     var s:sstr;
  767.     begin
  768.       s:=yesno (b);
  769.       getstr (t,s,1);
  770.       b:=upcase(s[1])='Y'
  771.     end;
  772.  
  773.     procedure removefile (n:integer);
  774.     var cnt:integer;
  775.     begin
  776.       for cnt:=n to numgfiles-1 do begin
  777.         seekgfile (cnt+1);
  778.         read (gfile,gf);
  779.         seekgfile (cnt);
  780.         write (gfile,gf)
  781.       end;
  782.       seekgfile (numgfiles);
  783.       truncate (gfile)
  784.     end;
  785.  
  786.     procedure addgfile;
  787.     var fn,s,p:anystr;
  788.         found:boolean;
  789.         t:text;
  790.     begin
  791.       found:=false;
  792.       writestr ('Filename: *');
  793.       if length(input)=0 then exit;
  794.       if match(input,'USERS') then begin
  795.        writelog (3,12,unam);
  796.        writeln (^G^M'Too bad, you can''t add the USER file!'^M);
  797.        exit;
  798.       end;
  799.       gf.fname:=input;
  800.       writestr ('Path [CR/'+gfa.gfileDir+']: *');
  801.       if length(input)=0 then input:=gfa.gfiledir;
  802.       gf.path:=input;
  803.       p:=gf.path;
  804.       if exist (faqdir+'SECURITY.DIR') then begin
  805.        assign (t,faqdir+'SECURITY.DIR');
  806.        reset (t);
  807.        repeat
  808.         readln (t,s);
  809.         if s[length(s)]<>'\' then s:=s+'\';
  810.         if match(s,p) then begin
  811.          found:=true;
  812.          writeln;
  813.          writeln (^G'That Directory is protected by the Sysop!');
  814.          writeln;
  815.         end;
  816.        until eof(t) or (found);
  817.        textclose (t);
  818.        if found then exit;
  819.       end;
  820.       writestr ('Archive Filename [CR/None]: *');
  821.       if length(input)<2 then gf.arcname:='' else
  822.       gf.arcname:=input;
  823.       if gf.arcname='' then begin
  824.         fn:=getfname(gf.path,gf.fname);
  825.         if not exist(fn) then begin
  826.           writestr ('File not found!  Enter file now? [y/n]: *');
  827.           if yes then makeasciigfile(fn)
  828.         end;
  829.         if not exist(fn) then exit;
  830.       end;
  831.       writestr ('Description:');
  832.       if length(input)=0 then exit;
  833.       gf.gfiledescr:=input;
  834.       writestr ('Sent by [CR/'+unam+']:');
  835.       if length(input)=0 then input:=unam;
  836.       gf.sentby:=input;
  837.       gf.filesize:=getfsize(fn);
  838.       gf.when:=now;
  839.       gf.downloaded:=0;
  840.       gf.specialfile:=false;
  841.       gf.newfile:=false;
  842.       seekgfile (numgfiles+1);
  843.       write (gfile,gf);
  844.       if gfilez>32760 then gfilez:=0;
  845.       gfilez:=gfilez+1;
  846.       if urec.lastgfiles>32760 then urec.lastgfiles:=0;
  847.       urec.lastgfiles:=urec.lastgfiles+1;
  848.       urec.gfuploads:=urec.gfuploads+1;
  849.       writelog (3,11,gf.gfiledescr);
  850.       writeurec
  851.     end;
  852.  
  853.     procedure editgfile;
  854.     var n:integer;
  855.         fn:anystr;
  856.     begin
  857.       n:=getgfilenum('Edit');
  858.       if n=0 then exit;
  859.       seekgfile (n);
  860.       read (gfile,gf);
  861.       getstr ('Filename',gf.fname,12);
  862.       getstr ('Path',gf.path,50);
  863.       getstr ('Archive Filename',gf.arcname,80);
  864.       if gf.arcname='' then begin
  865.        fn:=getfname(gf.path,gf.fname);
  866.        if not exist (fn) then begin
  867.         write (^B^M,fn,' not found!');
  868.         writestr (^M'Create new file '+fn+'? [y/n]: *');
  869.         if yes then makeasciigfile(fn);
  870.         if not exist(fn) then exit;
  871.        end else gf.filesize:=getfsize(fn);
  872.       end;
  873.       getstr ('Description',gf.gfiledescr,75);
  874.       getstr ('Uploader',gf.sentby,28);
  875.       getboo ('Special File',gf.specialfile);
  876.       getboo ('New file',gf.newfile);
  877.       seekgfile (n);
  878.       write (gfile,gf);
  879.       writelog (3,3,gf.gfiledescr);
  880.     end;
  881.  
  882.     procedure killgarea;
  883.     var gfatmp:gfilearea;
  884.         cnt,n:integer;
  885.         oldname,newname:sstr;
  886.     begin
  887.       gfatmp:=gfa;
  888.       writestr ('Delete Area #'+strr(curarea)+' ['+gfatmp.Name+']: *');
  889.       if not yes then exit;
  890.       gfilez:=gfilez-numgfiles;
  891.       urec.lastgfiles:=urec.lastgfiles-numgfiles;
  892.       if gfilez<0 then gfilez:=0;
  893.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  894.       close (gfile);
  895.       oldname:=uploaddir+'gfile'+strr(curarea);
  896.       assign (gfile,oldname);
  897.       erase (gfile);
  898.       for cnt:=curarea to numareas-1 do begin
  899.         newname:=oldname;
  900.         oldname:=uploaddir+'gfile'+strr(cnt+1);
  901.         assign (gfile,oldname);
  902.         rename (gfile,newname);
  903.         n:=ioresult;
  904.         Seekgfilea (cnt+1);
  905.         read (gfilea,gfatmp);
  906.         seekgfilea (cnt);
  907.         write (gfilea,gfatmp);
  908.       end;
  909.       seekgfilea (numareas);
  910.       truncate (gfilea);
  911.       setarea (1)
  912.     end;
  913.  
  914.     procedure modgarea;
  915.     var gfatmp:gfilearea;
  916.     begin
  917.       gfatmp:=gfa;
  918.       getstr ('Area Name',gfatmp.Name,80);
  919.       getint ('Access Level',gfatmp.Level);
  920.       getstr ('Sponsor',gfatmp.Sponsor,30);
  921.       getboo ('Able to Upload here',gfatmp.upable);
  922.       getstr ('Upload Dir',gfatmp.gfileDir,50);
  923.       seekgfilea (curarea);
  924.       write (gfilea,gfatmp);
  925.       gfa:=gfatmp;
  926.     end;
  927.  
  928.     procedure deletegfile;
  929.     var cnt,n,anarky:integer;
  930.         f:file;
  931.         gfn:lstr;
  932.         floyd:userrec;
  933.     begin
  934.       n:=getgfilenum ('Delete');
  935.       if n=0 then exit;
  936.       seekgfile (n);
  937.       read (gfile,gf);
  938.       gfn:=getfname(gf.path,gf.fname);
  939.       gfn:=upstring(gfn);
  940.       writeln;
  941.       writehdr ('Delete G-File');
  942.       writeln (^R'Filename:    '^S,gfn);
  943.       writeln (^R'Size:        '^S,strlong(gf.filesize));
  944.       writeln (^R'Description: '^S,gf.gfiledescr);
  945.       writeln (^R'Uploader:    '^S,gf.sentby);
  946.       writeln (^R);
  947.       writestr ('Delete this? [y/n]: *');
  948.       if not yes then exit;
  949.       writestr ('Erase Disk File '+gfn+'? *');
  950.       if yes then begin
  951.         if gf.arcname='' then begin
  952.         assign (f,getfname(gf.path,gf.fname));
  953.         erase (f);
  954.         if ioresult<>0 then writestr ('Couldn''t erase File.')
  955.        end else
  956.        writeln ('G-File is inside Archive; can''t erase it from here.');
  957.       end;
  958.       for cnt:=n+1 to numgfiles do begin
  959.         seekgfile (cnt);
  960.         read (gfile,gf);
  961.         seekgfile (cnt-1);
  962.         write (gfile,gf)
  963.       end;
  964.       seekgfile (numgfiles);
  965.       truncate (gfile);
  966.       if gfilez<0 then gfilez:=0;
  967.       gfilez:=gfilez-1;
  968.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  969.       urec.lastgfiles:=urec.lastgfiles-1;
  970.       writeurec;
  971.       writestr ('Remove Upload Credits from uploader? [y/n]: *');
  972.       if yes then begin
  973.        anarky:=lookupuser (gf.sentby);
  974.        if anarky<>0 then begin
  975.         writeurec;
  976.         seek (ufile,anarky);
  977.         read (ufile,floyd);
  978.         floyd.gfuploads:=floyd.gfuploads-1;
  979.         seek (ufile,anarky);
  980.         write (ufile,floyd);
  981.         readurec
  982.        end;
  983.       end;
  984.       writestr (^M'Deleted.');
  985.       writelog (3,4,gf.gfileDescr)
  986.     end;
  987.  
  988.     procedure SortGArea;
  989.     var temp,mark,cnt,method:integer;
  990.         v1,v2:string[80];
  991.         gftmp:gfileRec;
  992.     begin
  993.       writehdr ('Sort G-Files');
  994.       writeln;
  995.       writeln ('[0]:Quit');
  996.       writeln ('[1]:Description');
  997.       writeln ('[2]:Filename');
  998.       writeln;
  999.       writestr ('Enter method: *');
  1000.       method:=valu(input[1]);
  1001.       if method=0 then exit;
  1002.       mark:=numgfiles-1;
  1003.       repeat
  1004.         if mark<>0 then begin
  1005.           temp:=mark;
  1006.           mark:=0;
  1007.           for cnt:=1 to temp do begin
  1008.             seekgfile (cnt);
  1009.             read (gfile,gf);
  1010.             read (gfile,gftmp);
  1011.             if method=1 then begin
  1012.               v1:=upstring(gf.gfiledescr);
  1013.               v2:=upstring(gftmp.gfiledescr);
  1014.             end else begin
  1015.               v1:=upstring(gf.fname);
  1016.               v2:=upstring(gftmp.fname);
  1017.             end;
  1018.             if v1>v2 then begin
  1019.               mark:=cnt;
  1020.               seekgfile (cnt);
  1021.               write (gfile,gftmp);
  1022.               write (gfile,gf)
  1023.             end
  1024.           end
  1025.         end
  1026.       until mark=0
  1027.     end;
  1028.  
  1029.     procedure reordergareas;
  1030.     var cura,newa:integer;
  1031.         gfatmp:gfilearea;
  1032.         f1,f2:file;
  1033.         fn1,fn2:sstr;
  1034.     label exit;
  1035.     begin
  1036.       writehdr ('Reorder G-File Areas');
  1037.       writeln (^M'Number of G-File areas: ',numareas:1);
  1038.       for cura:=0 to numareas-2 do begin
  1039.         repeat
  1040.           writestr (^M^J+'New Area #'+strr(cura+1)+' [?/List]-[CR/Quit]:');
  1041.           if length(input)=0 then goto exit;
  1042.           if input='?' then begin
  1043.             listareas;
  1044.             newa:=-1
  1045.           end else begin
  1046.             newa:=valu(input)-1;
  1047.             if (newa<0) or (newa>=numareas) then begin
  1048.               writeln ('Not found!  Please re-enter...');
  1049.               newa:=-1
  1050.             end
  1051.           end
  1052.         until (newa>0);
  1053.         seek (gfilea,cura);
  1054.         read (gfilea,gfa);
  1055.         seek (gfilea,newa);
  1056.         read (gfilea,gfatmp);
  1057.         seek (gfilea,cura);
  1058.         write (gfilea,gfatmp);
  1059.         seek (gfilea,newa);
  1060.         write (gfilea,gfa);
  1061.         fn1:=uploaddir+'gfile';
  1062.         fn2:=fn1+strr(newa+1);
  1063.         fn1:=fn1+strr(cura+1);
  1064.         assign (f1,fn1);
  1065.         assign (f2,fn2);
  1066.         rename (f1,'Temp$$$$.%%%');
  1067.         rename (f2,fn1);
  1068.         rename (f1,fn2)
  1069.       end;
  1070.       exit:
  1071.       setarea (1)
  1072.     end;
  1073.  
  1074.     procedure Movegfile;
  1075.     var an,fn,old:integer;
  1076.         newfilesam,sambam,filesam,wangbang:anystr;
  1077.         darn:file;
  1078.         gftmp:gfileRec;
  1079.     begin
  1080.       fn:=GetgfileNum ('Move');
  1081.       old:=curarea;
  1082.       if fn=0 then exit;
  1083.       input:='';
  1084.       an:=GetAreaNum;
  1085.       if an=0 then exit;
  1086.       Seekgfile (fn);
  1087.       read (gfile,gftmp);
  1088.       if gftmp.arcname<>'' then begin
  1089.        writeln (^M'G-File is inside Archive ',gftmp.arcname,'. Cannot move.'^M);
  1090.        exit;
  1091.       end;
  1092.       removefile (fn);
  1093.       writestr('Physically move the file to correct area? *');
  1094.       write ('Moving...');
  1095.       filesam:=Getfname(gftmp.path,gftmp.fname);
  1096.       sambam:=gftmp.path;
  1097.       setarea(an);
  1098.       if (sambam<>gfa.gfileDir) then if yes then begin
  1099.         gftmp.path:=gfa.gfileDir;
  1100.         newfilesam:=Getfname(gftmp.path,gftmp.fname);
  1101.         exec('Copy',' '+filesam+' '+newfilesam+' >temp');
  1102.         wangbang:=filesam;
  1103.         assign(darn,wangbang);
  1104.         if exist(newfilesam) then erase (darn) else begin
  1105.           gftmp.path:=sambam;
  1106.           writeln('Uh oh... Bad error!');
  1107.         end;
  1108.       end;
  1109.       setarea (An);
  1110.       Addfile (gftmp);
  1111.       setarea (old);
  1112.       writeln (^B'Done.')
  1113.     end;
  1114.  
  1115.   procedure getpathname (fname:lstr; var path:lstr; var name:sstr);
  1116.   var p:integer;
  1117.   begin
  1118.     path:='';
  1119.     repeat
  1120.       p:=pos('\',fname);
  1121.       if p<>0 then begin
  1122.         path:=path+copy(fname,1,p);
  1123.         fname:=copy(fname,p+1,255)
  1124.       end
  1125.     until p=0;
  1126.     name:=fname
  1127.   end;
  1128.  
  1129.   procedure displayfile (var ffinfo:searchrec);
  1130.   var a:integer;
  1131.   begin
  1132.     a:=ffinfo.attr;
  1133.     if (a and 8)=8 then exit;
  1134.     tab (ffinfo.name,13);
  1135.     if (a and 16)=16
  1136.       then write ('Directory')
  1137.       else write (ffinfo.size);
  1138.     if (a and 1)=1 then write (' <read-only>');
  1139.     if (a and 2)=2 then write (' <hidden>');
  1140.     if (a and 4)=4 then write (' <system>');
  1141.     writeln
  1142.   end;
  1143.  
  1144.   procedure getfsize (var g:gfilerec);
  1145.   var df:file of byte;
  1146.   begin
  1147.     g.filesize:=-1;
  1148.     assign (df,getfname(g.path,g.fname));
  1149.     reset (df);
  1150.     if ioresult<>0 then exit;
  1151.     g.filesize:=filesize(df);
  1152.     close(df)
  1153.   end;
  1154.  
  1155.   procedure addresidentgfile (fname:lstr);
  1156.   var g:gfilerec;
  1157.       fn:anystr;
  1158.   begin
  1159.     getpathname (fname,g.path,g.fname);
  1160.     getfsize (g);
  1161.     if g.filesize=-1 then begin
  1162.       writeln ('File can''t be opened!');
  1163.       exit
  1164.     end;
  1165.       buflen:=70;
  1166.       writestr ('Description: &');
  1167.       g.gfiledescr:=input;
  1168.       getfsize (g);
  1169.       g.when:=now;
  1170.       g.sentby:=unam;
  1171.       g.downloaded:=0;
  1172.       g.specialfile:=false;
  1173.       g.newfile:=false;
  1174.       g.arcname:='';
  1175.       seekgfile (numgfiles+1);
  1176.       write (gfile,g);
  1177.       gfilez:=gfilez+1;
  1178.       writeln;
  1179.       writelog (3,11,g.gfiledescr)
  1180.   end;
  1181.  
  1182.   procedure addmultiplegfiles;
  1183.   var spath,pathpart:lstr;
  1184.       dummy:sstr;
  1185.       f:file;
  1186.       ffinfo:searchrec;
  1187.   begin
  1188.     if ulvl<sysoplevel then begin
  1189.       writeln (
  1190.         'Sorry, you may not add resident files without true sysop access!');
  1191.       exit
  1192.     end;
  1193.     writehdr ('Add Resident G-Files By Wildcard');
  1194.     writestr ('Search path/wildcard:');
  1195.     if length(input)=0 then exit;
  1196.     spath:=input;
  1197.     if spath[length(spath)]='\' then dec(spath[0]);
  1198.     assign (f,spath+'\con');
  1199.     reset (f);
  1200.     if ioresult=0 then begin
  1201.       close (f);
  1202.       spath:=spath+'\*.*'
  1203.     end;
  1204.     getpathname (spath,pathpart,dummy);
  1205.     findfirst (spath,$17,ffinfo);
  1206.     if doserror<>0
  1207.       then writeln ('No files found!')
  1208.       else
  1209.         while doserror=0 do begin
  1210.           writeln;
  1211.           displayfile (ffinfo);
  1212.           writestr ('Add this file? [Y/N/X]: *');
  1213.           if yes
  1214.             then addresidentgfile (getfname(pathpart,ffinfo.name))
  1215.             else if (length(input)>0) and (upcase(input[1])='X')
  1216.               then exit;
  1217.           findnext (ffinfo)
  1218.         end
  1219.   end;
  1220.  
  1221.   function defaultdrive:byte;
  1222.   var r:registers;
  1223.   begin
  1224.     r.ah:=$19;
  1225.     intr ($21,r);
  1226.     defaultdrive:=r.al+1
  1227.   end;
  1228.  
  1229.   function unsigned (i:integer):real;
  1230.   begin
  1231.     if i>=0
  1232.       then unsigned:=i
  1233.       else unsigned:=65536.0+i
  1234.   end;
  1235.  
  1236.   procedure writefreespace (path:lstr);
  1237.   var drive:byte;
  1238.       r:registers;
  1239.       csize,free,total:real;
  1240.   begin
  1241.     r.ah:=$36;
  1242.     r.dl:=ord(upcase(path[1]))-64;
  1243.     intr ($21,r);
  1244.     if r.ax=-1 then begin
  1245.       writeln ('Invalid drive');
  1246.       exit
  1247.     end;
  1248.     csize:=unsigned(r.ax)*unsigned(r.cx);
  1249.     free:=csize*unsigned(r.bx);
  1250.     total:=csize*unsigned(r.dx);
  1251.     free:=free/1024;
  1252.     total:=total/1024;
  1253.     writeln (free:0:0,'k out of ',total:0:0,'k')
  1254.   end;
  1255.  
  1256.   procedure directory;
  1257.   var r:registers;
  1258.       ffinfo:searchrec;
  1259.       tpath:anystr;
  1260.       b:byte;
  1261.       cnt:integer;
  1262.   begin
  1263.     getdir (defaultdrive,tpath);
  1264.     if tpath[length(tpath)]<>'\' then tpath:=tpath+'\';
  1265.     tpath:=tpath+'*.*';
  1266.     writestr ('Path/Wildcard [CR for '+tpath+']:');
  1267.     writeln (^M);
  1268.     if length(input)<>0 then tpath:=input;
  1269.     writelog (16,10,tpath);
  1270.     findfirst (chr(defaultdrive+64)+':\*.*',8,ffinfo);
  1271.     if doserror<>0
  1272.       then writeln ('No volume label'^M)
  1273.       else writeln ('Volume label: ',ffinfo.name,^M);
  1274.     findfirst (tpath,$17,ffinfo);
  1275.     if doserror<>0 then writeln ('No files found.') else begin
  1276.       cnt:=0;
  1277.       while doserror=0 do begin
  1278.         cnt:=cnt+1;
  1279.         if not break then displayfile (ffinfo);
  1280.         findnext (ffinfo)
  1281.       end;
  1282.       writeln (^B^M'Total Files: ',cnt)
  1283.     end;
  1284.     write ('Free Disk Space: ');
  1285.     writefreespace (tpath)
  1286.   end;
  1287.  
  1288.   begin
  1289.     if not issysop then begin
  1290.       reqlevel (sysoplevel);
  1291.       exit
  1292.     end;
  1293.     repeat
  1294.       q:=menu ('G-File Sysop','SGFILE','QACD?KRMSOW@F');
  1295.       case q of
  1296.         2:addgfile;
  1297.         3:editgfile;
  1298.         4:deletegfile;
  1299.         5:begin
  1300. writeln ('C╔═════════════════════════════════════╗Hs');
  1301. writeln ('uC║ G-File Sysop Section                ║Hs');
  1302. writeln ('uC╚═════════════════════════════════════╝HHC╔════s');
  1303. writeln ('u═════════════════════════════════╗HC║ [A]  s');
  1304. writeln ('uAdd G-Files                    ║HC║ [Cs');
  1305. writeln ('u]  Change G-File                  ║HC║ [s');
  1306. writeln ('uD]  Delete G-File                  ║Hs');
  1307. writeln ('uC║ [K]  Kill G-File Area               s');
  1308. writeln ('u║HC║ [M]  Move G-File             s');
  1309. writeln ('u       ║HC║ [N]  Newscan G-Files  s');
  1310. writeln ('u              ║HC║ [O]  Re-Order Gs');
  1311. writeln ('u-Files               ║HC║ [Q]  Quis');
  1312. writeln ('ut                           ║HC║ [R]  s');
  1313. writeln ('uRename G-File Area             ║HC║ [Ss');
  1314. writeln ('u]  Sort G-File Area               ║HC║ s');
  1315. writeln ('u[W]  Add Multiple G-Files           ║Hs');
  1316. writeln ('uC║ [?]  View This Menu                 s');
  1317. writeln ('u║HC╚═════════════════════════════════════╝');
  1318. writeln;
  1319. pause;
  1320.            end;
  1321.         6:killgarea;
  1322.         7:modgarea;
  1323.         8:movegfile;
  1324.         9:sortgarea;
  1325.         10:reordergareas;
  1326.         11:addmultiplegfiles;
  1327.         12:directory;
  1328.       end
  1329.     until hungupon or (q=1)
  1330.   end;
  1331.  
  1332. var prompt:lstr;
  1333.     n:integer;
  1334.     k:char;
  1335.     q1:mstr;
  1336.     a:arearec;
  1337.     ms:boolean;
  1338.     dammit:boolean;
  1339.     q:integer;
  1340.     x1,x2,x3,zxcv1,zxcv2:integer;
  1341.     y1,y2,y3:real;
  1342. begin
  1343.   dammit:=false;
  1344.   showit:=true;
  1345.   writehdr ('G-Files Section');
  1346.   writeln;
  1347.   itsotay:=false;
  1348.   {if numareas>0 then}
  1349.   opengfile;
  1350.   if not itsotay then exit;
  1351.   seekgfilea(1);
  1352.   read (gfilea,gfa);
  1353.   if (urec.gfLevel<gfa.Level) then begin
  1354.     writeln('You don''t have access to the G-Files Section.');
  1355.     exit;
  1356.   end;
  1357.   x1:=urec.nbu;
  1358.   x2:=urec.numon;
  1359.   if x1<1 then x1:=1;
  1360.   if x2<1 then x2:=1;
  1361.   y1:=int(x1);
  1362.   y2:=int(x2);
  1363.   y1:=y1;
  1364.   y2:=y2;
  1365.   y3:=y1/y2;
  1366.   y3:=y3*100;
  1367.   x3:=trunc(y3);
  1368.   write (^R'Required Post/Call Ratio: ['^S);
  1369.   for zxcv1:=1 to 3-(length(strr(gfpcr))) do write (' ');
  1370.   write (strr(gfpcr));
  1371.   writeln ('%'^R']');
  1372.   write (^R'Your Post/Call Ratio:     ['^S);
  1373.   for zxcv2:=1 to 3-(length(strr(x3))) do write (' ');
  1374.   write (strr(x3));
  1375.   writeln ('%'^R']');
  1376.   writeln;
  1377.   write (^R'PCR Status: ['^S);
  1378.   if ulvl>=pcrexempt then write ('Exempt from PCR.') else
  1379.   if (x3<gfpcr) and (ulvl<pcrexempt) then write ('PCR too low!') else
  1380.   if (x3>=gfpcr) and (ulvl<pcrexempt) then write ('Passed PCR check.');
  1381.   writeln (^R']');
  1382.   writeln;
  1383.   if (x3<gfpcr) and (ulvl<pcrexempt) then begin
  1384.    writeln (^B^R'Your Posts-per-Call Ratio is too low!');
  1385.    writeln ('Go post a message or two.');
  1386.    close (gfile);
  1387.    close (gfilea);
  1388.    exit;
  1389.   end;
  1390.   yourgfstatus;
  1391.     setarea(1);
  1392.   repeat
  1393.     prompt:='';
  1394.     q:=menu ('G-File','GFILE','QU%FAYNVDLG?');
  1395.     case q of
  1396.       1:begin
  1397.           close(gfile);
  1398.           close(gfilea);
  1399.         end;
  1400.       2:uploadgfile;
  1401.       3:sysopcommands;
  1402.       4:fastlistgfiles;
  1403.       5:getarea;
  1404.       6:yourgfstatus;
  1405.       7:newscanall;
  1406.       8:newscan;
  1407.       9:begin
  1408.           n:=getgfilenum ('Download');
  1409.           if n>0 then showgfile(n);
  1410.         end;
  1411.       10:fastlistgfiles;
  1412.       11:offfaq;
  1413.       12:begin
  1414. writeln ('C╔═════════════════════════════════════╗Hs');
  1415. writeln ('uC║ G-File Section                      ║Hs');
  1416. writeln ('uC╚═════════════════════════════════════╝HHC╔════s');
  1417. writeln ('u═════════════════════════════════╗HC║ [A]  s');
  1418. writeln ('uChange Active G-File Area      ║HC║ [Ds');
  1419. writeln ('u]  Download G-File                ║HC║ [s');
  1420. writeln ('uF]  Fast List G-Files              ║Hs');
  1421. writeln ('uC║ [G]  Log off BBS                    s');
  1422. writeln ('u║HC║ [L]  List G-Files            s');
  1423. writeln ('u       ║HC║ [N]  Newscan All G-Fils');
  1424. writeln ('ue Areas       ║HC║ [Q]  Quit      s');
  1425. writeln ('u                     ║HC║ [U]  Upls');
  1426. writeln ('uoad G-File                  ║HC║ [V]  s');
  1427. writeln ('uNewscan Current Area           ║HC║ [Ys');
  1428. writeln ('u]  Your G-File Statistics         ║HC║ s');
  1429. writeln ('u[%]  G-File Sysop Section           ║Hs');
  1430. writeln ('uC║ [?]  View This Menu                 s');
  1431. writeln ('u║HC╚═════════════════════════════════════╝');
  1432. writeln;
  1433. pause;
  1434.            end;
  1435.     end;
  1436.   until hungupon or (q=1);
  1437. end;
  1438.  
  1439. begin
  1440. end.
  1441.